﻿using HarmonyLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;

namespace RimZombieGirl
{
    [HarmonyPatch(typeof(Map), "Dispose")]
    public static class Map_Dispose_CurseCachePatch
    {
        public static void Prefix(Map __instance)
        {
            if (__instance == null) return;

            var manager = Current.Game.GetComponent<GameComponent_CurseManager>();
            if (manager == null) return;

            var comp = __instance.GetComponent<MapComponent_Curse>();
            if (comp != null && comp.GetCurrentCurseValue() > 0f)
            {
                manager.CacheMapCurse(__instance);
                Log.Message($"[CurseManager] Cached");
            }
        }
    }
}
